CREATE TABLE [finance].[JournalLineItems]
(
[JournalLineItemId] [bigint] NOT NULL IDENTITY(0, 1),
[LineSequenceId] [bigint] NOT NULL,
[JournalId] [bigint] NOT NULL,
[CustomerId] [bigint] NOT NULL,
[PostedDate] [datetime] NOT NULL,
[TxnTypeId] [bigint] NOT NULL,
[TxnType] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TxnDescription] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ChartOfAccountId] [bigint] NOT NULL,
[ChartOfAccountDesc] [nvarchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DRCRFlag] [nchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TxnAmount] [money] NOT NULL,
[LinkId] [bigint] NOT NULL,
[LinkSourceId] [bigint] NOT NULL,
[JournalTypeid] [tinyint] NULL,
[TxnAssociationId] [int] NULL,
[YYYYMM] [int] NOT NULL,
[IntPostedDate] AS ((datepart(year,[PostedDate])*(100)+datepart(month,[PostedDate]))*(100)+datepart(day,[PostedDate])),
[UpdateUser] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[UpdatedDate] [datetime] NOT NULL CONSTRAINT [CT_JournalLineItems_UpdatedDate] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [finance].[JournalLineItems] ADD CONSTRAINT [PK__JournalL__379A91FB4A4E069C] PRIMARY KEY CLUSTERED  ([JournalLineItemId]) ON [PRIMARY]
GO
ALTER TABLE [finance].[JournalLineItems] ADD CONSTRAINT [FK_JournalLineItems_JournalId] FOREIGN KEY ([JournalId]) REFERENCES [finance].[Journal] ([JournalId])
GO
